<?php

namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;

class OpenScreenUpdateRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        $hit_content_rule='';
        switch ($this->hit_type){
            case 'goods_detail':
                $hit_content_rule='|exists:goods,id';
                break;
            case 'goods_cate':
                $hit_content_rule='|exists:category,id';
                break;
            case 'link':
                $hit_content_rule='|url|string|max:100';
                break;
            case 'activity':
                $hit_content_rule='|in:1,2,3,4,5';
                break;
            default:
                $hit_content_rule='';
        }
        return [
            'title'  => 'required|string|max:100',
            'hit_type'  => 'required|string|in:goods_detail,goods_cate,link,activity',
            'hit_content'  => 'required'.$hit_content_rule,
            'thumb' => 'required|string|max:60',
            'weight' => 'required|integer',
            'second'=> 'required|integer|max:30',
            'start_time'  => 'required',
            'end_time' => 'required'
        ];
    }
}